// 对业务接口进行统一的管理
import {
	fetch
} from "./fetch.js";

// 对首页数据的请求
export const ApiGetHomeData = function() {
	return fetch('/index/index', {}, {}, 'GET');
}

// 登录接口
export const ApiLogin = (username, pwd) => fetch('/auth/loginByWeb', {
	username: username,
	pwd: pwd,
}, {})

// 品牌详情
export const Apibrand = (id) => fetch('/brand/detail', {
	id: id,
}, {}, 'GET')

// 分类宫格详情
export const Apigrid = (id) => fetch('/goods/category', {
	id: id,
}, {}, 'GET')

// 分类宫格详情列表
export const ApigridList = (categoryId, page, size) => fetch('/goods/list', {
	categoryId: categoryId,
	page: page,
	size: size,
}, {}, 'GET')
//全部商品分类接口  /catalog/index
export const ApiCataLog = function() {
	return fetch('/catalog/index', {}, {}, 'GET');
}

//当前分类 /catalog/current
export const ApiCurrentCataLog = function(id) {
	return fetch('/catalog/index', id, {}, 'GET');
}
// 专题接口
export const ApiTopic = ({
	page
}) => {
	return fetch('/topic/list', {
		page
	}, {}, 'GET');
}
// 新品详情
export const ApiDetails = (id) => fetch('/goods/detail', {
	id: id
}, {}, 'GET')
// 相关产品
export const ApiRelated = (id) => fetch('/goods/related', {
	id: id
}, {}, 'GET')


// 获取搜索历史
export const ApisearchHistory = (params) => fetch('/search/index', {}, {}, 'GET');
// 获取关键词列表
export const ApigetKeywordList = (keyword) => fetch('/search/helper', {
	keyword: keyword
}, {}, 'GET');
// 获取商品列表
export const ApigetGoodsList = (keyword) => fetch('/goods/list', {
	keyword: keyword
}, {}, 'GET');

//购物车
export const ApiCart = () => fetch('/cart/index', {}, {}, 'GET')
//切换商品
export const Apichecked = (pramse) => fetch('/cart/checked', pramse, {}, 'POST')

export const Apidel = (id) => fetch(`/cart/delete`, {
	productIds: id
}, {}, 'POST') //删除

export const Apiupdate = (goodsId, id, number, productId) => fetch('/cart/update',
	goodsId,
	id,
	number,
	productId, {}, 'POST') //步进器
